﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// enterprise_releasejob
	/// </summary>
	public partial class enterprise_releasejob
	{
		private readonly lcmyjobs.DAL.enterprise_releasejob dal=new lcmyjobs.DAL.enterprise_releasejob();
		public enterprise_releasejob()
		{}
          /// <summary>
        /// 使浏览次数+1
        /// </summary>
        /// <param name="enterprise_bid"></param>
        /// <returns></returns>
        public bool UpdateBcount(int enterprise_rid)
        {
            return dal.UpdateBcount(enterprise_rid);
        }
        public DataSet GetJobsInfo(bool isfrirt, bool reward, bool hunter, bool vip, bool newjob, bool workerclass,
                                   int atid, int currentPageIndex, int pageSize,
                                   out int c_isfrist, out int c_reward, out int c_hunter, out int c_vip, out int c_newjob, out int c_workerclass)
        {
            return dal.GetJobsInfo(isfrirt,reward,hunter,vip,newjob,workerclass,atid,currentPageIndex,pageSize,
                                   out c_isfrist,out c_reward,out c_hunter,out c_vip,out c_newjob,out c_workerclass);
        }
          /// <summary>
        /// 根据职位ID获取发布此职位的单位信息及职位信息
        /// </summary>
        /// <param name="enterprise_rid"></param>
        /// <returns></returns>
        public DataSet GetBasicAndJobsInfoByRid(int enterprise_rid)
        {
            return dal.GetBasicAndJobsInfoByRid(enterprise_rid);
        }
        /// <summary>
        /// 根据条件获取相应信息列表（hunter、reward、vip、newjobs）
        /// </summary>
        /// <param name="condition">（hunter猎头职位、reward悬赏职位、vip、newjobs最新职位）</param>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetJobsInfoByCondition(string condition, int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetJobsInfoByCondition(condition, atid, currentPageIndex, pageSize, out count);
        }
         /// <summary>
        /// 根据网站获取首页信息
        /// </summary>
        /// <param name="countH">猎头职位数量</param>
        /// <param name="countR">悬赏职位数量</param>
        /// <param name="countVIP">vip职位数</param>
        /// <param name="countNEW">最新招聘职位数</param>
        /// <param name="atid">网站</param>
        /// <returns></returns>
        public DataSet GetIndexInfo(int countH, int countR, int countVIP, int countNEW, int atid)
        {
            return dal.GetIndexInfo(countH, countR, countVIP, countNEW, atid);
        }
         /// <summary>
        /// 获取首页猎头职位
        /// </summary>
        /// <param name="countH"></param>
        /// <param name="atid"></param>
        /// <returns></returns>
        public DataSet GetIndexInfoHunter(int countH, int atid)
        {
            return dal.GetIndexInfoHunter(countH, atid);
        }
        /// <summary>
        /// 获取首页悬赏职位
        /// </summary>
        /// <param name="countR"></param>
        /// <param name="atid"></param>
        /// <returns></returns>
        public DataSet GetIndexInfoReward(int countR, int atid)
        {
            return dal.GetIndexInfoReward(countR, atid);
        }
        /// <summary>
        /// 获取首页VIP职位
        /// </summary>
        /// <param name="countVip"></param>
        /// <param name="atid"></param>
        /// <returns></returns>
        public DataSet GetIndexInfoVip(int countVip, int atid)
        {
            return dal.GetIndexInfoVip(countVip, atid);
        }
        /// <summary>
        /// 获取首页最新职位
        /// </summary>
        /// <param name="countNew"></param>
        /// <param name="atid"></param>
        /// <returns></returns>
        public DataSet GetIndexInfoNew(int countNew, int atid)
        {
            return dal.GetIndexInfoNew(countNew, atid);
        }




         /// <summary>
        /// 根据网站获取全部揭榜职位信息
        /// </summary>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetAllOfferJobdByAtid(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetAllOfferJobdByAtid(atid, currentPageIndex, pageSize, out count);
        }
       
         /// <summary>
        /// 根据网站获取全部悬赏职位
        /// </summary>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetAllRewardJobdByAtid(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetAllRewardJobdByAtid(atid, currentPageIndex, pageSize, out count);
        }
         /// <summary>
        /// 根据网站获取全部猎头职位
        /// </summary>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetAllHuntertJobdByAtid(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetAllHuntertJobdByAtid(atid, currentPageIndex, pageSize, out count);
        }
         /// <summary>
        /// 根据网站获取所有急聘职位信息
        /// </summary>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetAllIsFristRelesJobByAtid(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetAllIsFristRelesJobByAtid(atid,currentPageIndex,pageSize,out count);
        }
          /// <summary>
        /// 根据审核状态获取职位信息
        /// </summary>
        /// <param name="status"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetReleaseJobByStatus(int atid, int status, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetRelesJobByStatus(atid,status, currentPageIndex, pageSize, out count);
        }
          /// <summary>
        /// 获取VIP职位信息
        /// </summary>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetVipJobsInfo(int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetVipJobsInfo(currentPageIndex, pageSize, out count);
        }
         /// <summary>
        /// 根据条件获取所有职位信息
        /// </summary>
        /// <param name="condition">“isFrist”急聘职位，“isReward”悬赏职位</param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetReleaseJobsByCondition(string condition,int atid,string value, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetReleaseJobsByCondition(condition,atid, value,currentPageIndex,pageSize,out count);
        }
           /// <summary>
        /// 获取急聘职位
        /// </summary>
        /// <returns></returns>
        public DataSet GetIsFristJobs() 
        {
            return dal.GetIsFristJobs();
        }
         /// <summary>
        /// 职位搜索
        /// </summary>
        /// <param name="sj">搜索条件实体</param>
        /// <param name="count">返回行数</param>
        /// <returns></returns>
        public DataSet GetSearch(lcmyjobs.Model.searchjobs sj,int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetSearch(sj,atid,currentPageIndex,pageSize,out count);
        }
        /// <summary>
        ///  获取职位统计信息（包含应聘此职位的人数）
        /// </summary>
        /// <param name="enterprise_bid">企业ID</param>
        /// <param name="currentPageIndex">当前页</param>
        /// <param name="pageSize">每页显示条目数</param>
        /// <param name="count">总条目数</param>
        /// <returns>返回的DataSet第2个表为企业名称</returns>
        public DataSet Get_enterprise_releasejobtotal(int enterprise_bid, int currentPageIndex, int pageSize,int type, out int count)
        {
            return dal.Get_enterprise_releasejobtotal(enterprise_bid,currentPageIndex,pageSize,type, out count);
        }
         /// <summary>
        /// 批两个更改
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="value">更改值</param>
        /// <param name="where">更改条件enterprise_rid</param>
        /// <returns></returns>
        public bool UpdateWhere(string keywords, string value, string where)
        {
            return dal.UpdateWhere(keywords,value,where);
        }
          /// <summary>
        /// 得到发布职位信息（返回的dataset中表一发布职位基本信息，表二发布职位的地区，表三发布职位的专业）
        /// </summary>
        /// <param name="enterprise_rid"></param>
        /// <returns></returns>
        public DataSet GetReleaseJob(int enterprise_rid)
        {
            return dal.GetReleaseJob(enterprise_rid);
        }
        /// <summary>
        /// 得到发布职位信息（包括发布此职位的单位所发布的所有职位信息）
        /// </summary>
        /// <param name="enterprise_rid"></param>
        /// <returns>（返回的dataset中表一发布职位基本信息，表二发布职位的地区，表三发布职位的专业，表四 此单位所发布的所有职位信息，职位名和职位主键）</returns>
        public DataSet GetAllReleaseJob(int enterprise_rid, int atid)
        {
            return dal.GetAllReleaseJob(enterprise_rid,atid);
        }

        public bool isjob(int rid,string key, string val)
        {
            return dal.isjob(rid, key,val);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int enterprise_rid)
		{
			return dal.Exists(enterprise_rid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.enterprise_releasejob model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.enterprise_releasejob model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int enterprise_rid)
		{
			
			return dal.Delete(enterprise_rid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string enterprise_ridlist )
		{
			return dal.DeleteList(enterprise_ridlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.enterprise_releasejob GetModel(int enterprise_rid)
		{
			
			return dal.GetModel(enterprise_rid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.enterprise_releasejob GetModelByCache(int enterprise_rid)
		{
			
			string CacheKey = "enterprise_releasejobModel-" + enterprise_rid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(enterprise_rid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.enterprise_releasejob)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_releasejob> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_releasejob> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.enterprise_releasejob> modelList = new List<lcmyjobs.Model.enterprise_releasejob>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.enterprise_releasejob model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.enterprise_releasejob();
					if(dt.Rows[n]["enterprise_rid"]!=null && dt.Rows[n]["enterprise_rid"].ToString()!="")
					{
						model.enterprise_rid=int.Parse(dt.Rows[n]["enterprise_rid"].ToString());
					}
					if(dt.Rows[n]["enterprise_bid"]!=null && dt.Rows[n]["enterprise_bid"].ToString()!="")
					{
						model.enterprise_bid=int.Parse(dt.Rows[n]["enterprise_bid"].ToString());
					}
					if(dt.Rows[n]["enterprise_bh"]!=null && dt.Rows[n]["enterprise_bh"].ToString()!="")
					{
					model.enterprise_bh=dt.Rows[n]["enterprise_bh"].ToString();
					}
					if(dt.Rows[n]["jobs_id"]!=null && dt.Rows[n]["jobs_id"].ToString()!="")
					{
						model.jobs_id=int.Parse(dt.Rows[n]["jobs_id"].ToString());
					}
					if(dt.Rows[n]["jobclass"]!=null && dt.Rows[n]["jobclass"].ToString()!="")
					{
					model.jobclass=dt.Rows[n]["jobclass"].ToString();
					}
					if(dt.Rows[n]["workercount"]!=null && dt.Rows[n]["workercount"].ToString()!="")
					{
						model.workercount=int.Parse(dt.Rows[n]["workercount"].ToString());
					}
					if(dt.Rows[n]["jobdep"]!=null && dt.Rows[n]["jobdep"].ToString()!="")
					{
					model.jobdep=dt.Rows[n]["jobdep"].ToString();
					}
					if(dt.Rows[n]["salarym"]!=null && dt.Rows[n]["salarym"].ToString()!="")
					{
						model.salarym=dt.Rows[n]["salarym"].ToString();
					}
					if(dt.Rows[n]["salaryy"]!=null && dt.Rows[n]["salaryy"].ToString()!="")
					{
						model.salaryy=dt.Rows[n]["salaryy"].ToString();
					}
					if(dt.Rows[n]["validity"]!=null && dt.Rows[n]["validity"].ToString()!="")
					{
						model.validity=int.Parse(dt.Rows[n]["validity"].ToString());
					}
					if(dt.Rows[n]["workerclass"]!=null && dt.Rows[n]["workerclass"].ToString()!="")
					{
						model.workerclass=int.Parse(dt.Rows[n]["workerclass"].ToString());
					}
					if(dt.Rows[n]["edus_id"]!=null && dt.Rows[n]["edus_id"].ToString()!="")
					{
						model.edus_id=int.Parse(dt.Rows[n]["edus_id"].ToString());
					}
					if(dt.Rows[n]["workexp_id"]!=null && dt.Rows[n]["workexp_id"].ToString()!="")
					{
						model.workexp_id=int.Parse(dt.Rows[n]["workexp_id"].ToString());
					}
					if(dt.Rows[n]["jobduty"]!=null && dt.Rows[n]["jobduty"].ToString()!="")
					{
					model.jobduty=dt.Rows[n]["jobduty"].ToString();
					}
					if(dt.Rows[n]["jobrequirement"]!=null && dt.Rows[n]["jobrequirement"].ToString()!="")
					{
					model.jobrequirement=dt.Rows[n]["jobrequirement"].ToString();
					}
					if(dt.Rows[n]["releasetime"]!=null && dt.Rows[n]["releasetime"].ToString()!="")
					{
						model.releasetime=DateTime.Parse(dt.Rows[n]["releasetime"].ToString());
					}
					if(dt.Rows[n]["isuse"]!=null && dt.Rows[n]["isuse"].ToString()!="")
					{
						if((dt.Rows[n]["isuse"].ToString()=="1")||(dt.Rows[n]["isuse"].ToString().ToLower()=="true"))
						{
						model.isuse=true;
						}
						else
						{
							model.isuse=false;
						}
					}
					if(dt.Rows[n]["languages_id"]!=null && dt.Rows[n]["languages_id"].ToString()!="")
					{
						model.languages_id=int.Parse(dt.Rows[n]["languages_id"].ToString());
					}
                    if (dt.Rows[n]["languages_level"] != null && dt.Rows[n]["languages_level"].ToString() != "")
                    {
                        model.languages_level = dt.Rows[n]["languages_level"].ToString();
                    }
					if(dt.Rows[n]["bcount"]!=null && dt.Rows[n]["bcount"].ToString()!="")
					{
						model.bcount=int.Parse(dt.Rows[n]["bcount"].ToString());
					}
					if(dt.Rows[n]["isfrist"]!=null && dt.Rows[n]["isfrist"].ToString()!="")
					{
						if((dt.Rows[n]["isfrist"].ToString()=="1")||(dt.Rows[n]["isfrist"].ToString().ToLower()=="true"))
						{
						model.isfrist=true;
						}
						else
						{
							model.isfrist=false;
						}
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

